package beautiful.butterfly.distributed_task_processing_engine.tools;

/**
 * 拆分算法
 */
public class Allots
{


    /**
     * 分配
     */
    public static int[] allot(int taskItemNum, int serverNum)
    {
        int[] ints = new int[serverNum];
        int num = taskItemNum / serverNum;
        int left = taskItemNum % serverNum;
        for (int i = 0; i < ints.length; i++)
        {
            if (i < left)
            {
                ints[i] = num + 1;
            } else
            {
                ints[i] = num;
            }
        }
        return ints;
    }

}
